/*************************************************************************
	> File Name: iterator_test.cc
	> Author: likang
	> Mail:  
	> Created Time: 2014年12月24日 星期三 15时09分31秒
 ************************************************************************/

#include<iostream>
#include<iterator>
#include<fstream>
#include<vector>
#include<algorithm>
using namespace std;

int main(void) {

	//read ints from cin
	istream_iterator<int> cin_it(cin);
	//end iterator value
	istream_iterator<int> end_of_stream;
	ofstream outfile("outputfile.txt");
	ostream_iterator<int> output(cout," ");
	ostream_iterator<int> outputfile(outfile," ");
	/*while (cin_it != end_of_stream) {
		*output++ = *cin_it;
		*outputfile++ = *cin_it++;
	}*/

	//与算法一起使用流迭代器
	
	vector<int> ivec(cin_it,end_of_stream);
	sort(ivec.begin(),ivec.end());
	unique_copy(ivec.begin(),ivec.end(),output);
	unique_copy(ivec.begin(),ivec.end(),outputfile);

	return 0;

}
